package com.game.gameObject
{
	import flash.display.*;
	import flash.geom.*;
	import com.game.gameHandle.*;
	
	public class GameObject extends BaseObject
	{		
		//物件位置
		public var position:Point = new Point(0, 0);
		//图片资源
		public var graphics:GraphicsResource = null;
		
		public function GameObject()
		{
			super();
		}
		
		public function startupGameObject(graphics:GraphicsResource, position:Point, zOrder:int = 0):void
		{
			if (!inuse)
			{
				super.startupBaseObject(zOrder);			
				this.graphics = graphics;
				this.position = position.clone();				
				
			}
		}
		
		override public function shutdown():void
		{
			if (inuse)
			{				
				super.shutdown();
				graphics = null;							
			}
		}
		
		override public function copyToBackBuffer(db:BitmapData):void
		{
			db.copyPixels(graphics.bitmap, graphics.bitmap.rect, position, graphics.bitmapAlpha, new Point(0, 0), true);
		}
	}
}